package com.fbms.config.Interceptor;


import com.fbms.common.utils.UserHolder;
import com.fbms.module.auth.Bean.LoginUserDTO;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 类描述：TODO
 *
 * @ClassName LoginInterceptor
 * @Author HappyBoy
 * @Date 2022-11-20 15:12
 **/
public class LoginInterceptor implements HandlerInterceptor {

    /**
     * 前置拦截
     * @param request current HTTP request
     * @param response current HTTP response
     * @param handler chosen handler to execute, for type and/or instance evaluation
     * @return
     * @throws Exception
     */
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // 获取用户信息
        LoginUserDTO userDTO = UserHolder.getUser();
//        if(userDTO == null){
//            // 不存在 返回前端401（无权限） 拦截
//            response.setStatus(401);
//            return false;
//        }

        return true;
    }

}
